﻿using System;
using CNav.Domain;
using FluentValidation;

namespace CNav.Business.Validation
{
    public class ConsumerValidation : AbstractValidator<Consumer>
    {
        public ConsumerValidation()
        {
            RuleFor(b => b.Title).NotEmpty().Length(2, 6).WithMessage("Title must be atleast 2 character long.");
            RuleFor(b => b.FirstName).NotEmpty().WithMessage("Please provide firstname");
            RuleFor(b => b.LastName).NotEmpty().WithMessage("Please provide lastname");
            RuleFor(b => b.BirthDate).LessThanOrEqualTo(DateTime.UtcNow.AddYears(-18)).WithMessage("Sorry, but you must be at least 18 years of age");
             
            RuleFor(b => b.Email).EmailAddress().WithMessage("Please specify a email address.");
            RuleFor(b => b.PhoneNumber).Must(ValidatorUtils.IsPhone).WithMessage("Please specify a valid phone number.");
        }
    }
}